using UnityEngine;

public class SceneRenderData : MonoBehaviour
{
    [System.Serializable]
    public struct RendererInfo
    {
        public Renderer renderer;
        public int lightmapIndex;
        public Vector4 lightmapOffsetScale;
    }

    [SerializeField]
    public RendererInfo[] m_RendererInfo;

    void Start()
    {
        if (m_RendererInfo == null || m_RendererInfo.Length == 0)
            return;

        ApplyRendererInfo(m_RendererInfo);
    }

    void ApplyRendererInfo(RendererInfo[] infos)
    {
        for (int i = 0; i < infos.Length; i++)
        {
            var info = infos[i];
            if (info.renderer)
            {
                info.renderer.lightmapIndex = info.lightmapIndex;
                info.renderer.lightmapScaleOffset = info.lightmapOffsetScale;
                Material[] mat = info.renderer.sharedMaterials;
                for (int j = 0; j < mat.Length; j++)
                {
                    if (mat[j] != null && Shader.Find(mat[j].shader.name) != null)
                        mat[j].shader = Shader.Find(mat[j].shader.name);
                }
            }
        }


    }
}